# coding: UTF-8
# ----------
# Project_Name : pythonProject
# File_Name : huangcongbing
# Author : asus
# Date_Time:2022/4/27 13:41
# Description :
# ----------
import unittest  # 导入测试框架

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait  # 导入显式等待类
from selenium.webdriver.support import expected_conditions  # 导入等待条件
from selenium.webdriver.common.action_chains import ActionChains

class zhyzptest(unittest.TestCase):  #必须继承Tescase
    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.wait = WebDriverWait(self.driver,30)
        self.driver.maximize_window()
        self.driver.get("http://192.168.2.6/cloud/#/my")

    def test(self):
        #登录
        self.wait.until(expected_conditions.visibility_of_element_located((By.XPATH,'//*[@id="account"]/input')))
        self.driver.find_element(By.XPATH,'//*[@id="account"]/input').send_keys("admin")
        self.driver.find_element(By.XPATH,'//*[@id="password"]/input').send_keys("123456")
        self.driver.find_element(By.XPATH,'//*[@id="authCode"]/div/input').send_keys("8888")
        self.driver.find_element(By.XPATH,'//*[@id="root"]/div/div[1]/form/div[5]/div/div').click()

        # 人员管理
        self.wait.until(expected_conditions.visibility_of_element_located(
            (By.XPATH, '//*[@id="root"]/section/aside/div/ul/li[3]')))
        self.driver.find_element(By.XPATH, '//*[@id="root"]/section/aside/div/ul/li[3]').click()  # 点击人员管理
        # time.sleep(5)#调试时间

        self.wait.until(expected_conditions.visibility_of_element_located((By.XPATH, '//*[@id="system$Menu"]/li')))
        self.driver.find_element(By.XPATH, '//*[@id="system$Menu"]/li').click()  # 点击人员列表

        #  修改人员信息
        self.driver.find_elements(By.CLASS_NAME,'ant-checkbox-wrapper')[2].click()#勾选胡啦的选框
        self.driver.find_element(By.XPATH,'//*[@id="root"]/section/section/main/div/div[1]/button[3]').click()#点击修改
        self.driver.find_element(By.ID,'phone').clear()#清楚原有的号码
        self.driver.find_element(By.ID,'phone').send_keys('13512345678')#输入新的电话号码
        self.driver.find_element(By.ID, 'email').clear()  # 清楚原有的号码
        self.driver.find_element(By.ID, 'email').send_keys('6666666@qq.com')  # 输入新的电话号码
        time.sleep(2)
        self.driver.find_elements(By.CLASS_NAME,'ant-btn')[6].click()
        time.sleep(5)







    def tearDown(self) -> None:
        self.driver.quit()